//
//  UIDevice+Info.m
//  Amily
//
//  Created by 张鹏 on 15/6/29.
//  Copyright (c) 2015年 Amily. All rights reserved.
//

#import "UIDevice+Info.h"
#import "sys/utsname.h"
@implementation UIDevice (Info)

+ (BOOL)iOS10 {
    NSString *sysVersion = [self currentDevice].systemVersion;
    return [sysVersion floatValue] >= 10.0;
}

+ (BOOL)iOS9 {
    NSString *sysVersion = [self currentDevice].systemVersion;
    return [sysVersion floatValue] >= 9.0;
}


+ (BOOL)iOS8Later {
  NSString *sysVersion = [self currentDevice].systemVersion;
  if ([sysVersion floatValue] >= 8.0) {
    return YES;
  }
  return NO;
}

+ (BOOL)iOS7 {
    NSString *sysVersion = [self currentDevice].systemVersion;
    if ([sysVersion floatValue] < 8.0) {
        return YES;
    }
    return NO;
}


+ (BOOL)is4InchiPhone {
  CGRect mainScreen = [[UIScreen mainScreen] bounds];
  if (mainScreen.size.width == 320) {
    return YES;
  } else {
    return NO;
  }
}

+ (BOOL)isiPhone6 {
    CGRect mainScreen = [[UIScreen mainScreen] bounds];
    if (mainScreen.size.width == 375) {
        return YES;
    } else {
        return NO;
    }
}


+ (BOOL)isPlus {
  CGRect mainScreen = [[UIScreen mainScreen] bounds];
  if (mainScreen.size.width == 414) {
    return YES;
  } else {
    return NO;
  }
}

+ (NSString*)deviceVersion
{
    struct utsname systemInfo;
    uname(&systemInfo);
    NSString *deviceString = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
    
    if ([deviceString isEqualToString:@"iPhone5,1"])    return @"iPhone 5";
    if ([deviceString isEqualToString:@"iPhone5,2"])    return @"iPhone 5";
    if ([deviceString isEqualToString:@"iPhone5,3"])    return @"iPhone 5C";
    if ([deviceString isEqualToString:@"iPhone5,4"])    return @"iPhone 5C";
    if ([deviceString isEqualToString:@"iPhone6,1"])    return @"iPhone 5S";
    if ([deviceString isEqualToString:@"iPhone6,2"])    return @"iPhone 5S";
    if ([deviceString isEqualToString:@"iPhone7,1"])    return @"iPhone 6 Plus";
    if ([deviceString isEqualToString:@"iPhone7,2"])    return @"iPhone 6";
    if ([deviceString isEqualToString:@"iPhone8,1"])    return @"iPhone 6s";
    if ([deviceString isEqualToString:@"iPhone8,2"])    return @"iPhone 6s Plus";
    
    return deviceString;
}


+ (NSString *)uuid
{
    NSUUID *uuid = [UIDevice currentDevice].identifierForVendor;
    return uuid.UUIDString;
}

+ (NSString *)model
{
   return [UIDevice currentDevice].model;
}

+ (NSString *)localizedModel
{
    return [UIDevice currentDevice].localizedModel;
}

+ (NSString *)deviceName
{
    return [UIDevice currentDevice].name;
}

@end
